package io;

import java.io.*;
import java.nio.charset.StandardCharsets;

public class PWDemo {
    public static void main(String[] args) throws IOException {
        //最常用写入字符串方式：
        PrintWriter pw = new PrintWriter("pw.txt");
        pw.println("哦");
        pw.println("啊");
        System.out.println("写出完毕");
        pw.close();

        /*
        FileOutputStream fos = new FileOutputStream("pw.txt");//文件流
        OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8);//转换流
        BufferedWriter bw = new BufferedWriter(osw);//缓冲字符流
        bw.write("哦");
        bw.write("啊");
        System.out.println("写出完毕");
        bw.close();//先调用flush()冲水

         */
    }
}
